package com.swuwen.ssh.hiring.action;

import com.opensymphony.xwork2.ActionSupport;
import com.swuwen.ssh.hiring.entity.TalentEntity;
import com.swuwen.ssh.hiring.service.TalentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * Created by Administrator on 2017/3/3 0003.
 */
@Controller
public class TalentAction extends ActionSupport {
    @Autowired
    private TalentService talentService;

    /*
        接受前台传来的数据
     */
    private String code;
    private String password;

    /*
       setter方法
     */
    public void setCode(String code) {
        this.code = code;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    /*
        业务处理部分
    */

    /**
     * 登录部分
     *
     * @return
     */
    public String login() {
        TalentEntity loginInfo = talentService.userLogin(this.code, this.password);
        if (loginInfo == null) {
            return "loginDefeated";
        } else {
            return "loginSucceed";
        }
    }

    /**
     * 跳转至主页
     *
     * @return
     */
    public String homepage() {
        return "homepage";
    }
}